<html xmlns="http://www.w3c.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<script type="text/javascript">
		//<![CDATA[
		//debe usarse los \\:  en lugar de : en los selectores de JQuery
		$(document).ready(function() {
			wizardSetCurrentPageStyle('form_wizard:associativityData');
		});
		//]]>
	</script>
</h:head>
<h:body>
	<h:form id="form_associativity_data">
		<h2>
			<h:outputLabel value="#{i18n['lbl.owner.associativity.title']}" />
		</h2>
		<div class="clearfix common-panel">
			<div class="ui-form-row-2col clearfix">
				<div class="ui-form-col">
					<div class="clearfix text-align-left">
						<h:outputLabel
							value="#{i18n['lbl.owner.associativity.part_of_organization']}" />
					</div>
					<div class="clearfix text-align-left">
						<p:selectOneRadio id="radioPartOfOrganinization"
							value="#{aSession.selectedRuatRegister.associationsMembership}"
							onchange="disabledFuction();">
							<f:selectItem itemLabel="Si" itemValue="1" />
							<f:selectItem itemLabel="No" itemValue="2" />
							<f:ajax event="click" render="reasonNotToBelongId" />
							<f:ajax event="click" render="tableAsInt" />
						</p:selectOneRadio>
					</div>
				</div>
				<p:blockUI block="cmbUp" widgetVar="bui2" />
				<p:panel id ="cmbUp">
				<div class="ui-form-col">
					<div class="clearfix text-align-left">
						<h:outputLabel
							value="#{i18n['lbl.owner.associativity.not_to_belong_associativity']}" />
					</div>
					<div class="clearfix text-align-left">
						<p:blockUI block="reasonNotToBelongId" widgetVar="bui" />
						<p:selectOneMenu
							value="#{aSession.selectedRuatRegister.reasonNotToBelong}"
							id="reasonNotToBelongId" required="#{aSession.selectedRuatRegister.associationsMembership==2}" disabled="#{aSession.selectedRuatRegister.associationsMembership==1}">
							<f:selectItem itemLabel="#{i18n['cmpnt.type_or_select']}"
								itemValue="" noSelectionOption="true"/>
							<f:selectItems
								value="#{reasonNotToBelongCmb.parameterDTO.options}" />
						</p:selectOneMenu>
					</div>
				</div>
				</p:panel>
				
			</div>
		</div>

		<div class="clearfix common-panel">
		<p:blockUI block="tableAs" widgetVar="buiAs" />
		<p:panel id ="tableAs">
		<p:panel id ="tableAsInt">
			<p:commandButton value="#{i18n['cmpnt.new']}"
				styleClass="ui-flowbutton"
				actionListener="#{associativityController.createNewRegister}"
				update="tableAs" id="btnNew" disabled="#{aSession.selectedRuatRegister.associationsMembership==2}"/>
			<p:blockUI block="btnNew" widgetVar="buibtnNew" />
			<p:dataTable var="register"
				value="#{aSession.associativity.associativityRegisters}"
				emptyMessage="#{i18n['cmpnt.no.data']}"
				id="tableassociativityRegisters">
				<p:column headerText="#{i18n['lbl.owner.associativity.class']}">
					<p:selectOneMenu value="#{register.associationClass}" required="#{aSession.selectedRuatRegister.associationsMembership==1}">
						<f:selectItem itemLabel="#{i18n['cmpnt.select_one']}" itemValue="" noSelectionOption="true"/>
						<f:selectItems value="#{classCmb.parameterDTO.options}" />
					</p:selectOneMenu>
				</p:column>

				<p:column headerText="#{i18n['lbl.owner.associativity.org_name']}">
					<p:inputText value="#{register.organizationName}" required="#{aSession.selectedRuatRegister.associationsMembership==1}"/>
				</p:column>

				<p:column headerText="#{i18n['lbl.owner.associativity.benefit']}">
					<p:selectOneMenu value="#{register.benefit}" required="#{aSession.selectedRuatRegister.associationsMembership==1}">
						<f:selectItem itemLabel="#{i18n['cmpnt.select_one']}" itemValue="" noSelectionOption="true"/>
						<f:selectItems value="#{benefitCmb.parameterDTO.options}" />
						<f:selectItem itemLabel="#{i18n['cmpnt.other']}"
									itemValue="3"  />						
					</p:selectOneMenu>
				</p:column>

				<p:column
					headerText="#{i18n['lbl.owner.associativity.meeting_frequency']}">
					<p:selectOneMenu value="#{register.meetingFrequency}" required="#{aSession.selectedRuatRegister.associationsMembership==1}">
						<f:selectItem itemLabel="#{i18n['cmpnt.select_one']}" itemValue="" />
						<f:selectItems value="#{meetingFrequencyCmb.parameterDTO.options}" />
					</p:selectOneMenu>
				</p:column>
				<p:column
					headerText="#{i18n['lbl.owner.associativity.work_Organization']}">
					<p:selectOneMenu value="#{register.workInOrganization}" required="#{aSession.selectedRuatRegister.associationsMembership==1}">
						<f:selectItem itemLabel="#{i18n['cmpnt.select_one']}" itemValue="" noSelectionOption="true"/>
						<f:selectItems
							value="#{workInOrganizationCmb.parameterDTO.options}" />
					</p:selectOneMenu>
				</p:column>
			</p:dataTable>
			<p:blockUI block="tableassociativityRegisters"
				widgetVar="buitableassociativityRegisters" />
			</p:panel>	
			</p:panel>	
		</div>

		<div class="clearfix common-panel">
			<div class="ui-form-row-2col clearfix">
				<div class="ui-form-col">
					<div class="clearfix text-align-left">
						<h:outputLabel
							value="#{i18n['lbl.owner.associativity.entities_associativity']}" />
					</div>
					<div class="clearfix text-align-left">
						<p:selectOneRadio id="radioEntitiesProvidingSupport"
							value="#{aSession.selectedRuatRegister.entitiesProvidingSupport}"
							>
							<f:selectItem itemLabel="Si" itemValue="1" />
							<f:selectItem itemLabel="No" itemValue="2" />
							<f:ajax event="click" render="providingSupport" />
						</p:selectOneRadio>
					</div>
				</div>
				<div class="ui-form-col">
					<p:blockUI block="providingSupport" widgetVar="buiEntities" />
<!-- 					<p:panel id="providingSupport" > -->
<!-- 					 <h:panelGrid columns="1" onmouseover="">  -->
							<div class="clearfix text-align-left">
								<h:outputLabel
									value="#{i18n['lbl.owner.associativity.name_entity']}" />
							</div>

							<div class="clearfix text-align-left">
								<p:inputText
									value="#{aSession.selectedRuatRegister.entitiesProvidingSupportName}" id="providingSupport" required="#{aSession.selectedRuatRegister.entitiesProvidingSupport==1}" disabled="#{aSession.selectedRuatRegister.entitiesProvidingSupport==2}"/>
							</div>
<!-- 						</h:panelGrid> -->
<!-- 					</p:panel> -->
				</div>

			</div>
		</div>
		<div class="buttons-container clearfix text-align-right">
			<p:commandButton value="#{i18n['lbl.flow_button.cancel']}"
				styleClass="ui-flowbutton"
				oncomplete="currentPage('list_owner_data.xhtml')"
				actionListener="#{stepByStepController.cancelRuatRegister}" />
			<p:commandButton value="#{i18n['lbl.flow_button.back']}"
				oncomplete="setCurrentPageStyle(xhr, status, args,this)"
				styleClass="ui-flowbutton" update="form_associativity_data"
				actionListener="#{stepByStepController.viewInnovationData}" />
			<p:commandButton value="#{i18n['lbl.flow_button.save_and_next']}"
				oncomplete="setCurrentPageStyle(xhr, status, args,this)"
				styleClass="ui-flowbutton" validateClient="true"
				update="form_associativity_data"
				actionListener="#{stepByStepController.viewAssociativityDataB}"  
				id="savenext" />
		</div>
		<p:blockUI block="savenext" trigger="savenext"/>
	</h:form>
</h:body>
<script type="text/javascript">
	//<![CDATA[
	//debe usarse los \\:  en lugar de : en los selectores de JQuery
	$(document).ready(function() {
		disabledFuction();
		disabledFuctionEntities();
	});
	function disabledFuction() {
		var valor = $(
				'input[name=form_associativity_data\\:radioPartOfOrganinization]:checked')
				.val();
		if (valor == 1) {
// 			$('#form_associativity_data\\:btnNew').removeAttr('disabled');
			PF('buitableassociativityRegisters').hide();
			PF('buibtnNew').hide();
			PF('bui').show();
			PF('bui2').show();
			PF('buiAs').hide();
		} else {
// 			$('#form_associativity_data\\:btnNew').attr('disabled', 'true');
			PF('buitableassociativityRegisters').show();
			PF('buibtnNew').show();
			PF('bui').hide();
			PF('bui2').hide();
			PF('buiAs').show();
		}

	}
	function disabledFuctionEntities() {
		var valor = $(
				'input[name=form_associativity_data\\:radioEntitiesProvidingSupport]:checked')
				.val();
		if (valor == 1) {
			PF('buiEntities').hide();// esta linea no hace nada :(
			$('#form_associativity_data\\:providingSupport').removeAttr(
					'disabled').removeClass('ui-state-disabled');
		} else {
			PF('buiEntities').show(); // esta lineano hace nada :(
			$('#form_associativity_data\\:providingSupport').attr('disabled',
					'true').addClass('ui-state-disabled');
		}
	}
	//]]>
</script>
</html>